package com.yxq.mdt.app.modules.order.ui.adapter;

import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.glide.GlideHelper;
import com.yxq.mdt.app.modules.order.bean.OrderDetailBean;
import com.yxq.mdt.app.modules.order.bean.OrderRefundPreviewBean;

import java.util.List;

/**
 * @author L
 * @time 2019-10-21
 * @describe 申请售后预览界面商品列表
 */
public class OrderRefundPreviewGoodsListAdapter extends BaseQuickAdapter<OrderRefundPreviewBean, BaseViewHolder> {

    public OrderRefundPreviewGoodsListAdapter(int layoutResId, @Nullable List<OrderRefundPreviewBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderRefundPreviewBean item) {

        GlideHelper.setLoadRoundImage(mContext, item.getGoods_pic(), 0, helper.getView(R.id.order_confirm_goods_list_iv_img));
        TextView nameView = helper.getView(R.id.cart_tv_name);
        if (nameView != null) {
            nameView.setText(item.getName());

            helper.setText(R.id.cart_tv_attr, (item.getAttr() != null && item.getAttr().size() > 0) ? item.getAttr().get(0).getAttr_name() : "规格：默认");
            helper.setText(R.id.cart_tv_price, String.format("￥%.2f", item.getTotal_price()));
        }

        helper.setText(R.id.tv_num, item.getNum() + "");
    }

    @Override
    public int getItemCount() {
        //最多只显示5件商品
        return getData().size() > 5 ? 5 : getData().size();
    }
}
